package com.wayne.blog.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wayne.blog.entity.ArticleLike;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * 文章喜欢Mapper接口
 */
@Mapper
public interface ArticleLikeMapper extends BaseMapper<ArticleLike> {
    
    /**
     * 查询用户是否喜欢文章
     */
    @Select("SELECT COUNT(*) FROM article_like WHERE article_id = #{articleId} AND user_id = #{userId} AND deleted = 0")
    int checkLike(Long articleId, Long userId);

    /**
     * 查询文章喜欢数
     */
    @Select("SELECT COUNT(*) FROM article_like WHERE article_id = #{articleId} AND deleted = 0")
    int getLikeCount(Long articleId);
} 